<template>
  <el-card class="box-card">
    <div>
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="tableData"
        border
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          type="index"
          :index="Method"
          prop="id"
          width="55"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="order_id" align="center" label="订单编号">
        </el-table-column>
        <el-table-column prop="name" align="center" label="商品名称">
        </el-table-column>
        <el-table-column prop="ctime" align="center" label="下单日期">
        </el-table-column>
        <el-table-column prop="nickname" align="center" label="购买用户名称">
        </el-table-column>
        <!-- <el-table-column align="center" label="水票图片">
          <template slot-scope="scope">
            <el-image
              style="width: 80px; height: 80px"
              :src="scope.row.water_img"
              fit="cover"
            ></el-image>
          </template>
        </el-table-column> -->
        <el-table-column prop="mobile" align="center" label="用户手机号">
        </el-table-column>
        <el-table-column prop="nums" align="center" label="商品数量">
        </el-table-column>
        <el-table-column prop="amount" align="center" label="金额">
        </el-table-column>
      </el-table>
      <div class="pageUser">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
    <!-- <el-dialog
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
    >
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="packGit"
        border
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          type="index"
          width="55"
          :index="Method"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="water_name" align="center" label="水票名称">
        </el-table-column>
        <el-table-column prop="goods_cat_name" align="center" label="水票类型">
        </el-table-column>
        <el-table-column prop="package_nember" align="center" label="水票数量">
        </el-table-column>
        <el-table-column prop="water_img" align="center" label="水票图片">
          <template slot-scope="scope">
            <el-image
              style="width: 80px; height: 80px"
              :src="scope.row.water_img"
              fit="cover"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="goods_name" align="center" label="商品名称">
        </el-table-column>
        <el-table-column prop="brand_name" align="center" label="水品牌">
        </el-table-column>
        <el-table-column prop="payed" align="center" label="售票金额">
        </el-table-column>
      </el-table>
      <div class="pageUser">
        <el-pagination
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1"
          :current-page="page1"
          :page-sizes="[10, 150, 200, 300]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total1"
        >
        </el-pagination>
      </div>
    </el-dialog> -->
  </el-card>
</template>

<script>
// import {
//   packageCount,
//   packageIndex,
//   classification,
// } from "../../../../utils/api.js";
import { shuiPiaoDetail } from "../../../../utils/main";
export default {
  data() {
    return {
      token: sessionStorage.getItem("token"),
      dialogVisible: false,
      //请求特效
      loading: false,
      // form: {
      //   name: "",
      //   mobile: "",
      //   time: "",
      // },
      time: "",
      //发送请求时间参数
      //展示数据
      tableData: [
        // {
        //   water_name: "",
        //   goods_cat_name: "",
        //   water_number: "",
        //   id: "",
        //   brand_name: "",
        //   goods_name: "",
        //   water_img: "",
        //   ctime: "",
        //   buy_count: "",
        //   water_cat_id: "",
        //   ctime: "",
        // },
      ],
      //明细
      // packGit: [
      //   {
      //     water_nameL: "",
      //     goods_cat_name: "",
      //     package_nember: "",
      //     goods_name: "",
      //     brand_name: "",
      //     water_img: "",
      //     ctime: "",
      //     payed: "",
      //   },
      // ],
      //水票类型
      // Data: [
      //   {
      //     id: "",
      //     name: "",
      //   },
      // ],
      page: 1,
      limit: 10,
      total: 0,
      // page1: 1,
      // limit1: 10,
      // total1: 0,
      water_id: "",
      time: "",
    };
  },
  methods: {
    //日期
    timeChange(e) {
      console.log(e);
      let list = [];
      e.forEach((item) => {
        let date = new Date(item);
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
        let h = date.getHours();
        let min = date.getMinutes();
        let s = date.getSeconds();
        month = month < 10 ? "0" + month : month;
        day = day < 10 ? "0" + day : day;
        h = h < 10 ? "0" + h : h;
        min = min < 10 ? "0" + min : min;
        s = s < 10 ? "0" + s : s;
        list.push(
          year + "-" + month + "-" + day + " " + h + ":" + min + ":" + s
        );
      });

      this.time = list[0] + "," + list[1];
      console.log(this.time);
    },
    //查询
    onSubmit(row) {
      this.getList();
    },
    //水票分类
    selectChange() {},
    //分页器
    handleSizeChange(val) {
      this.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getList();
    },
    // handleSizeChange1(val) {
    //   this.limit1 = val;
    //   this.packageIndexs();
    // },
    // handleCurrentChange1(val) {
    //   this.page1 = val;
    //   this.packageIndexs();
    // },
    // 序号排序
    Method(index) {
      if (this.token < this.limit) {
        return this.total - index;
      } else {
        return this.total - (this.page - 1) * this.limit - index;
      }
    },
    // 获取出售商品一览表详情
    async getList() {
      this.loading = true;
      let res = await shuiPiaoDetail(
        this.token,
        this.page,
        this.limit,
        this.water_id,
        this.time
      );
      if (res.data.status) {
        this.tableData = res.data.data.data || [];
        this.total = res.data.data.count;
        // console.log(this.total, shouchu);
        let timer = setTimeout(() => {
          this.loading = false;
          clearTimeout(timer);
        }, 400);
      } else {
        if (res.data.msg == "token失效,请重新进行登录") {
          this.$router.push("/login");
        }
        if (res.data.msg == "此账号没有权限") {
          this.$message.error(res.data.msg);
          this.loading = false;
        }
        let timer = setTimeout(() => {
          this.$message.error(res.data.msg);
        }, 5000);
      }
    },
    //获取列表数据
    // packageCounts() {
    //   this.loading = true;
    //   packageCount(
    //     this.token,
    //     this.page,
    //     this.limit,
    //     this.form.mobile,
    //     this.time,
    //     this.form.name
    //   )
    //     .then((res) => {
    //       if (res.data.status) {
    //         this.tableData = res.data.data.data;
    //         this.total = res.data.data.count;
    //         this.tableData.forEach((item) => {
    //           if (item.water_img) {
    //             item.water_img1 = item.water_img;
    //             item.water_img = "https://bjsf.bjsky.top" + item.water_img;
    //           }
    //         });
    //         let timer = setTimeout(() => {
    //           this.loading = false;
    //           clearTimeout(timer);
    //         }, 400);
    //       } else {
    //         if (res.data.msg == "token失效,请重新进行登录") {
    //           this.$router.push("/login");
    //         }
    //         if (res.data.msg == "此账号没有权限") {
    //           this.$message.error(res.data.msg);
    //           this.loading = false;
    //         }
    //         let timer = setTimeout(() => {
    //           this.$message.error(res.data.msg);
    //         }, 5000);
    //       }
    //     })
    //     .catch((err) => {
    //       console.log(err.message);
    //     });
    // },
    // //明细列表数据
    // packageIndexs() {
    //   this.loading = true;
    //   packageIndex(this.token, this.page1, this.limit1, this.tableData.id, "")
    //     .then((res) => {
    //       if (res.data.status) {
    //         this.packGit = res.data.data.date;
    //         this.total1 = res.data.data.count;
    //         console.log(this.total1);
    //         this.packGit.forEach((item) => {
    //           if (item.water_img) {
    //             item.water_img1 = item.water_img;
    //             item.water_img = "https://bjsf.bjsky.top" + item.water_img;
    //           }
    //         });
    //         let timer = setTimeout(() => {
    //           this.loading = false;
    //           clearTimeout(timer);
    //         }, 400);
    //       } else {
    //         if (res.data.msg == "token失效,请重新进行登录") {
    //           this.$router.push("/login");
    //         }
    //         if (res.data.msg == "此账号没有权限") {
    //           this.$message.error(res.data.msg);
    //           this.loading = false;
    //         }
    //         let timer = setTimeout(() => {
    //           this.$message.error(res.data.msg);
    //         }, 5000);
    //       }
    //     })
    //     .catch((err) => {
    //       console.log(err.message);
    //     });
    // },
    //水票分类
    // sdhadj() {
    //   this.loading = true;
    //   classification(this.token)
    //     .then((res) => {
    //       if (res.data.status) {
    //         this.Data = res.data.data.data;

    //         let timer = setTimeout(() => {
    //           this.loading = false;
    //           clearTimeout(timer);
    //         }, 400);
    //       } else {
    //         if (res.data.msg == "token失效,请重新进行登录") {
    //           this.$router.push("/login");
    //         }
    //         if (res.data.msg == "此账号没有权限") {
    //           this.$message.error(res.data.msg);
    //           this.loading = false;
    //         }
    //         let timer = setTimeout(() => {
    //           this.$message.error(res.data.msg);
    //         }, 5000);
    //       }
    //     })
    //     .catch((err) => {
    //       console.log(err.message);
    //     });
    // },
    //关闭弹窗
    handleClose(done) {
      done();
      this.packageCounts();
    },
  },
  mounted() {
    // this.packageCounts();
    // this.sdhadj();
    this.water_id = this.$route.query.water_id;
    this.getList();
  },
};
</script>

<style scoped></style>
